package com.tester.zc.test002.runnable;

/**
 * 消费者
 *
 * @Author zhoucan
 * @Date 2022/12/11
 */
public class Consumer implements Runnable {
    @Override
    public void run() {
        while (true) {
            synchronized (Constant.object) {
                try {
                    //唤醒等待的线程
                    Constant.object.notify();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!Constant.flag) {
                    System.out.println(Thread.currentThread().getName() + "消费了一个包子");
                    Constant.flag = true;
                }
            }
        }
    }
}
